import { Space, Table, Tag, Input, Dropdown, Button, Upload, message, Form, Empty } from 'antd';
import { newActicle } from '@/utils/works';
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
import React, { useState, useEffect } from 'react';
import axios from "@/utils/request"
import { InboxOutlined } from '@ant-design/icons';
import styles from './poster.less';
// import "./posterwork.less"

type Props = {}

const Posterwork = (props: Props) => {
let [ipt,setipt]=useState('')
  useEffect(() => {
    axios.get("http://111.67.198.176:8103/api/file?page=1&pageSize=12").then(res => {
      // setlist(res.data.data[0])
    })
  }, [])

  //------------------------
  let [list, setlist] = useState([])
  const handleUpload = (e: newActicle) => {
   
  }
  //-----------------------
let btn = ()=>{
  axios.get(`http://111.67.198.176:8103/api/file?page=1&pageSize=12&originalname=${ipt}`).then(res=>{
  // setlist(res.data.data[0])
  setipt('')
  })
}

  return (
    <div className={styles.posterbox}>
      <div className={styles.posterUplod}>
        <Form.Item name="cover">
          <div className='UplodJPG'>
            <InboxOutlined className="Jpgs" />
            {/* <img className={setIMG.url ? styles.IMGs : styles.imgs} src={setIMG.url ? setIMG.url : edit_value.id ? searchIMG.cover ? searchIMG.cover : '' : ''} alt="" /> */}
            <input id='file' type="file" onChange={handleUpload} />
            <p className="ant-upload-text">点击选择文件或将文件拖拽到此处</p>
            <p className="ant-upload-hint">文件将上传到OSS,如未配置请先配置</p>
          </div>
        </Form.Item>
      </div>


      <div className={styles.content}>
        <div className={styles.From}>
          <p> 文件名称:<Input placeholder="请输入用户账户" onChange={(e)=>{setipt(e.target.value)}} value={ipt} /></p>
        </div>
        <div className={styles.btns}>
          <Button className={styles.search} onClick={()=>{btn()}}>搜索</Button>
          <Button className={styles.chong}>重置</Button>
        </div>

      </div>
      <div className={styles.table}>
        {
          // <img className={setIMG.url ? styles.IMGs : styles.imgs} src={setIMG.url ? setIMG.url : edit_value.id ? searchIMG.cover ? searchIMG.cover : '' : ''} alt="" />
         list.length ? list.map((item: newActicle, index) => {
            return <div className={styles.img}>
              <img src={item.url} alt="" />
              <p>{item.originalname}</p>
            </div>
          }) : < Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
        }
      </div>
    </div>
  )
}

export default Posterwork